package com.mongoproject.database;

import java.net.UnknownHostException;

import com.mongodb.BasicDBObject;
import com.mongodb.DB;
import com.mongodb.DBCollection;
import com.mongodb.Mongo;

/**
 * This class create random Data and store them in to Mongodb Database.
 * @author Xuejian Sun
 *
 */
public class Data_Script {
	static DBCollection items = null; 
	static Mongo mongo = null;
	static DB db=null;
	public void generateData (String s1, String s2) throws UnknownHostException{
		
		int N=1000;
		mongo = new Mongo();
	    db = mongo.getDB(s1 );
        items = db.getCollection(s2 );
        System.out.println(s1+" "+ s2);
        String Name="Name";
        String NameVal="Michael";
        for(int i=0; i<N; i++){
        	BasicDBObject employee = new BasicDBObject().append(Name, NameVal+i);
        	//System.out.println(NameVal+i);
            String name="_id";
        	String str="1000"+i;
        	employee.put(name, str);
            items.insert(employee);
        }
     
		
	}

}
